package cn.qh.com.entity;

import java.util.ArrayList;
import java.util.Date;


import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.activerecord.Model;

import java.io.Serializable;

import lombok.*;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;

import java.util.Date;
import java.util.List;

import com.fasterxml.jackson.annotation.JsonFormat;

/**
 * 商品三级分类(Category)表实体类
 *
 * @author makejava
 * @since 2021-11-27 09:57:08
 */
@Setter
@Getter
@AllArgsConstructor
@NoArgsConstructor
@Builder
@TableName(value = "category")
@SuppressWarnings("serial")
public class Category extends Model<Category> implements Comparable<Category> {


    @TableId(value = "catId", type = IdType.AUTO)
    private Long catId;  //分类id


    @TableField(value = "name")
    private String name;  //分类名称


    @TableField(value = "parentcid")
    private Long parentcid;  //父分类id


    @TableField(value = "catlevel")
    private Integer catlevel;  //层级


    @TableField(value = "sort")
    private Integer sort;  //排序


    @TableField(value = "icon")
    private String icon;  //图标地址


    @TableField(value = "productunit")
    private String productunit;  //计量单位


    @TableField(value = "productcount")
    private Integer productcount;  //商品数量


    @Version
    private int version;   //版本


    @TableLogic
    @TableField(fill = FieldFill.INSERT)
    private int deleted;  //逻辑删除标志


    @TableField(value = "createdTime")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createdTime;  //创建时间


    @TableField(value = "updatedTime")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date updatedTime;  //修改时间


    @Override
    public int compareTo(Category o) {
        return ((o == null || o.getSort() == null) ? 0 : o.getSort())
                - (this.getSort() == null ? 0 : this.getSort());
    }

    @TableField(exist = false)
    private List<Category> categoryList = new ArrayList<>();
}
